<template>
  <view v-if="shenheStatus == 0" class="add-card">
    <view class="form-section">
      <u-form
        :model="form"
        ref="uForm"
        labelAlign="center"
        :borderBottom="true"
        label-width="160rpx"
      >
        <u-form-item :label="$t('user.cardAcc')">
          <u-input v-model="form.account" :placeholder="$t('user.noCardAcc')" />
        </u-form-item>
        <u-form-item :label="$t('user.cardPass')">
          <u-input
            v-model="form.cardpwd"
            :placeholder="$t('user.noCardPass')"
          />
        </u-form-item>
      </u-form>
    </view>

    <view class="submit-bt" @click="onSubmit">{{ $t('user.band') }}</view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
export default {
  components: { Shenhe },
  data() {
    return {
      form: {
        account: '',
        cardpwd: '',
      },
    };
  },
  methods: {
    async onSubmit() {
      try {
        if (!this.form.account.length) throw this.$t('user.noAcc');
        if (!this.form.cardpwd.length) throw this.$t('user.noPass');
        const res = await this.$allrequest.coupon.verifyAdd(this.form);

        uni.showToast({
          title: res.msg,
          duration: 2000,
        });
        // this.$utils.toast(res.msg);
        setTimeout(() => {
          uni.navigateBack({
            delta: 1,
          });
        }, 2000);
      } catch (error) {
        // this.$utils.toast(error || error.msg);
      }
    },
  },
};
</script>

<style lang="scss">
.add-card {
  width: 100%;
  background: #f2f2f2;
  min-height: 100vh;
  .form-section {
    width: 100%;
    background-color: #ffffff;
    padding-left: 24rpx;
    /deep/.u-form-item {
      padding: 18rpx 0 !important;
      .u-form-item--left__content__label {
        justify-content: flex-start !important;
      }
    }
  }
}
.submit-bt {
  margin: 80rpx auto 0;
  width: 90.4vw;
  height: 88rpx;
  line-height: 88rpx;
  text-align: center;
  background: #f0250e;
  border-radius: 120rpx;
  font-size: 32rpx;
  color: #ffffff;
}
</style>
